﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using RTUParameterConfig.Class;

namespace RTUParameterConfig
{
    public partial class Section : UserControl
    {
        public int intIndex;
        public int intFss;
        public int intDms;

        public Section(int index)
        {
            InitializeComponent();
            intIndex = index;
        }

        protected override void CreateHandle()
        {
            if (!IsHandleCreated)
            {
                try
                {
                    base.CreateHandle();
                }
                catch { }
                finally
                {
                    if (!IsHandleCreated)
                    {
                        base.RecreateHandle();
                    }
                }
            }
        }

        public void InitPanel(Panel p)
        {
            p.Visible = true;
            this.Width = p.Width;
            this.Height = p.Height;
            p.Location = new Point(0, 0);
            p.Refresh();
        }

        /// <summary>
        /// 初始断面选择配置参数
        /// </summary>
        /// <param name="intFs">流量计算方式</param>
        /// <param name="intDm">流量槽断面选择</param>
        public void InitShow(int intFs, int intDm)
        {
            intFss = intFs;
            intDms = intDm;
            if (intIndex == 0)
            {
                if (intFs == 0)
                {
                    if (intDm == 0)
                    {
                        InitPanel(p7);
                        nud71.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud72.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter12.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 1)
                    {
                        InitPanel(p10);
                        nud101.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud102.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter12.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 2)
                    {
                        InitPanel(p11);
                        nud111.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud112.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter12.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud113.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter13.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud114.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter14.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 3)
                    {
                        InitPanel(p12);
                        nud121.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud122.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter13.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud123.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter14.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 4)
                    {
                        InitPanel(p13);
                        nud131.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud132.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter12.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 5)
                    {
                        InitPanel(p14);
                        nud141.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud142.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter12.Reverse<byte>().ToArray(), 0) / 100.0);
                    }
                }

                if (intFs == 1 || intFs == 3)
                {
                    if (intDm == 0)
                    {
                        InitPanel(p2);
                        nud22.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud23.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud24.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter12.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 1)
                    {
                        InitPanel(p3);
                        nud32.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud33.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud34.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter12.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 2)
                    {
                        InitPanel(p4);
                        nud42.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud43.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud44.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter12.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud45.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter13.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 3)
                    {
                        InitPanel(p5);
                        nud52.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud53.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter12.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 4)
                    {
                        InitPanel(p8);
                        nud82.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud83.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud84.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter12.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud85.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter13.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud86.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter14.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 5)
                    {
                        InitPanel(p6);
                        nud62.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud63.Value = ParameterConfig.rtuConfigInfo.WaterFlowSectionHeightResolution[0];
                    }

                    if (intDm == 6)
                    {
                        InitPanel(new Panel());
                    }
                }

                if (intFs == 2)
                {
                    if (intDm == 0)
                    {
                        InitPanel(p9);
                        nud91.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter11.Reverse<byte>().ToArray(), 0) / 100.0);
                    }
                }

                if (intFs == 4)//多流速
                {
                    if (intDm == 0)
                    {
                        InitPanel(p15);
                        
                    }
                }
            }

            if (intIndex == 1)
            {
                if (intFs == 0)
                {
                    if (intDm == 0)
                    {
                        InitPanel(p7);
                        nud71.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud72.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter22.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 1)
                    {
                        InitPanel(p10);
                        nud101.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud102.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter22.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 2)
                    {
                        InitPanel(p11);
                        nud111.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud112.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter22.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud113.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter23.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud114.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter24.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 3)
                    {
                        InitPanel(p12);
                        nud121.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud122.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter23.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud123.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter24.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 4)
                    {
                        InitPanel(p13);
                        nud131.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud132.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter22.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 5)
                    {
                        InitPanel(p14);
                        nud141.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud142.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter22.Reverse<byte>().ToArray(), 0) / 100.0);
                    }
                }

                if (intFs == 1 || intFs == 3 || intFs == 4)
                {
                    if (intDm == 0)
                    {
                        InitPanel(p2);
                        nud22.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud23.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud24.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter22.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 1)
                    {
                        InitPanel(p3);
                        nud32.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud33.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud34.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter22.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 2)
                    {
                        InitPanel(p4);
                        nud42.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud43.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud44.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter22.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud45.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter23.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 3)
                    {
                        InitPanel(p5);
                        nud52.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud53.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter22.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 4)
                    {
                        InitPanel(p8);
                        nud82.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud83.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud84.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter22.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud85.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter23.Reverse<byte>().ToArray(), 0) / 100.0);
                        nud86.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter24.Reverse<byte>().ToArray(), 0) / 100.0);
                    }

                    if (intDm == 5)
                    {
                        InitPanel(p6);
                        nud62.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2.Reverse<byte>().ToArray(), 0) / 1000.0);
                        nud63.Value = ParameterConfig.rtuConfigInfo.WaterFlowSectionHeightResolution[1];
                    }

                    if (intDm == 6)
                    {
                        InitPanel(new Panel());
                    }
                }

                if (intFs == 2)
                {
                    if (intDm == 0)
                    {
                        InitPanel(p9);
                        nud91.Value = Convert.ToDecimal(BitConverter.ToUInt16(ParameterConfig.rtuConfigInfo.WaterFlowParameter21.Reverse<byte>().ToArray(), 0) / 100.0);
                    }
                }
            }
        }

        /// <summary>
        /// 获取断面选择配置参数
        /// </summary>
        public void GetValue()
        {
            if (intIndex == 0)
            {
                if (intFss == 0)
                {
                    if (intDms == 0)
                    {
                        InitPanel(p7);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud71.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter12 = BitConverter.GetBytes(Convert.ToUInt16(nud72.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 1)
                    {
                        InitPanel(p10);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud101.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter12 = BitConverter.GetBytes(Convert.ToUInt16(nud102.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 2)
                    {
                        InitPanel(p11);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud111.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter12 = BitConverter.GetBytes(Convert.ToUInt16(nud112.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter13 = BitConverter.GetBytes(Convert.ToUInt16(nud113.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter14 = BitConverter.GetBytes(Convert.ToUInt16(nud114.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 3)
                    {
                        InitPanel(p12);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud121.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter13 = BitConverter.GetBytes(Convert.ToUInt16(nud122.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter14 = BitConverter.GetBytes(Convert.ToUInt16(nud123.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 4)
                    {
                        InitPanel(p13);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud131.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter12 = BitConverter.GetBytes(Convert.ToUInt16(nud132.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 5)
                    {
                        InitPanel(p14);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud141.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter12 = BitConverter.GetBytes(Convert.ToUInt16(nud142.Value * 100)).Reverse<byte>().ToArray();
                    }
                }

                if (intFss == 1 || intFss == 3 || intFss == 4)
                {
                    if (intDms == 0)
                    {
                        InitPanel(p2);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud21.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1 = BitConverter.GetBytes(Convert.ToUInt16(nud22.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud23.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter12 = BitConverter.GetBytes(Convert.ToUInt16(nud24.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 1)
                    {
                        InitPanel(p3);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud31.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1 = BitConverter.GetBytes(Convert.ToUInt16(nud32.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud33.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter12 = BitConverter.GetBytes(Convert.ToUInt16(nud34.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 2)
                    {
                        InitPanel(p4);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud41.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1 = BitConverter.GetBytes(Convert.ToUInt16(nud42.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud43.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter12 = BitConverter.GetBytes(Convert.ToUInt16(nud44.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter13 = BitConverter.GetBytes(Convert.ToUInt16(nud45.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 3)
                    {
                        InitPanel(p5);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud51.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1 = BitConverter.GetBytes(Convert.ToUInt16(nud52.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter12 = BitConverter.GetBytes(Convert.ToUInt16(nud53.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 4)
                    {
                        InitPanel(p8);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud81.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1 = BitConverter.GetBytes(Convert.ToUInt16(nud82.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud83.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter12 = BitConverter.GetBytes(Convert.ToUInt16(nud84.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter13 = BitConverter.GetBytes(Convert.ToUInt16(nud85.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter14 = BitConverter.GetBytes(Convert.ToUInt16(nud86.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 5)
                    {
                        InitPanel(p6);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud61.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth1 = BitConverter.GetBytes(Convert.ToUInt16(nud62.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowSectionHeightResolution[0] = Convert.ToByte(nud63.Value);
                    }

                    if (intDms == 6)
                    {
                        //InitPanel(p1);
                    }
                }

                if (intFss == 2)
                {
                    if (intDms == 0)
                    {
                        InitPanel(p9);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter11 = BitConverter.GetBytes(Convert.ToUInt16(nud91.Value * 100)).Reverse<byte>().ToArray();
                    }
                }
            }

            if (intIndex == 1)
            {
                if (intFss == 0)
                {
                    if (intDms == 0)
                    {
                        InitPanel(p7);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud71.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter22 = BitConverter.GetBytes(Convert.ToUInt16(nud72.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 1)
                    {
                        InitPanel(p10);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud101.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter22 = BitConverter.GetBytes(Convert.ToUInt16(nud102.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 2)
                    {
                        InitPanel(p11);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud111.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter22 = BitConverter.GetBytes(Convert.ToUInt16(nud112.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter23 = BitConverter.GetBytes(Convert.ToUInt16(nud113.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter24 = BitConverter.GetBytes(Convert.ToUInt16(nud114.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 3)
                    {
                        InitPanel(p12);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud121.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter23 = BitConverter.GetBytes(Convert.ToUInt16(nud122.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter24 = BitConverter.GetBytes(Convert.ToUInt16(nud123.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 4)
                    {
                        InitPanel(p13);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud131.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter22 = BitConverter.GetBytes(Convert.ToUInt16(nud132.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 5)
                    {
                        InitPanel(p14);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud141.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter22 = BitConverter.GetBytes(Convert.ToUInt16(nud142.Value * 100)).Reverse<byte>().ToArray();
                    }
                }

                if (intFss == 1 || intFss == 3 || intFss == 4)
                {
                    if (intDms == 0)
                    {
                        InitPanel(p2);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud21.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2 = BitConverter.GetBytes(Convert.ToUInt16(nud22.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud23.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter22 = BitConverter.GetBytes(Convert.ToUInt16(nud24.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 1)
                    {
                        InitPanel(p3);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud31.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2 = BitConverter.GetBytes(Convert.ToUInt16(nud32.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud33.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter22 = BitConverter.GetBytes(Convert.ToUInt16(nud34.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 2)
                    {
                        InitPanel(p4);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud41.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2 = BitConverter.GetBytes(Convert.ToUInt16(nud42.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud43.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter22 = BitConverter.GetBytes(Convert.ToUInt16(nud44.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter23 = BitConverter.GetBytes(Convert.ToUInt16(nud45.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 3)
                    {
                        InitPanel(p5);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud51.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2 = BitConverter.GetBytes(Convert.ToUInt16(nud52.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter22 = BitConverter.GetBytes(Convert.ToUInt16(nud53.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 4)
                    {
                        InitPanel(p8);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud81.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2 = BitConverter.GetBytes(Convert.ToUInt16(nud82.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud83.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter22 = BitConverter.GetBytes(Convert.ToUInt16(nud84.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter23 = BitConverter.GetBytes(Convert.ToUInt16(nud85.Value * 100)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter24 = BitConverter.GetBytes(Convert.ToUInt16(nud86.Value * 100)).Reverse<byte>().ToArray();
                    }

                    if (intDms == 5)
                    {
                        InitPanel(p6);
                        //rtuConfigInfo.WaterFlowHeights[intIndex] = Convert.ToUInt16(nud61.Value * 1000);
                        ParameterConfig.rtuConfigInfo.WaterFlowSiltationDepth2 = BitConverter.GetBytes(Convert.ToUInt16(nud62.Value * 1000)).Reverse<byte>().ToArray();
                        ParameterConfig.rtuConfigInfo.WaterFlowSectionHeightResolution[1] = Convert.ToByte(nud63.Value);
                    }

                    if (intDms == 6)
                    {
                        //InitPanel(p1);
                    }
                }

                if (intFss == 2)
                {
                    if (intDms == 0)
                    {
                        InitPanel(p9);
                        ParameterConfig.rtuConfigInfo.WaterFlowParameter21 = BitConverter.GetBytes(Convert.ToUInt16(nud91.Value * 100)).Reverse<byte>().ToArray();
                    }
                }
            }
        }
    }
}
